<!--
 * @description: 新增分销中心
 * @Author: latiao
 * @Date: 2021-11-08 16:49:33
 * @LastEditors: vikingShip
 * @LastEditTime: 2022-02-09 14:47:24
-->
<template>
  <view >
    <view class="distrib__header" >
      <view class="distrib__userinfo" >
        <image class="distrib__userinfo__img" :src="userInfo.avatarUrl"/>
        <view class="distrib__userinfo__name" >{{userInfo.nikeName}}</view>
      </view>
      <button open-type="share" class="distrib__header--link" >分享链接</button >
    </view>
    <view class="distrib__commission">
      <view class="distrib__commission--word" >当前累计佣金收益(元)</view>
      <view class="distrib__commission--num" >{{totalDistributionAmount}}</view>
      <view class="distrib__commission--notes" >不包含待结算佣金</view>
    </view>
    <view class="distrib__customer" @click="gotocustomer" >
      <view class="flex">
        <image class="distrib__customer--img"  src="https://medusa-small-file-1253272780.cos.ap-shanghai.myqcloud.com/gruul/20211108/aa8dba6cd22a44849b615123cdcc5a41.png"/>
        <view >分销客户</view>
      </view>
      <view >{{distributionUserCount}}></view>
    </view>
    <view class="distrib__code" @click="gotocode">
      <view class="flex">
        <image class="distrib__code--img" src="https://medusa-small-file-1253272780.cos.ap-shanghai.myqcloud.com/gruul/20211108/dc8faab86695455e8b6a26b4ea38e485.png"/>
        <view >推广二维码</view>
      </view>
      <view >></view>
    </view>
  </view>
</template>

<script lang='ts'>
  import {
    Component,
    Vue
  } from 'vue-property-decorator'
  import {
    distributionGet,
  } from "@/api/modules/distribution";
   import {
     userIdGet
    } from "@/api/modules/user";

  @Component({})
export default class DistributionCenter extends Vue {
  distributionUserCount:number=null
  totalDistributionAmount:number=0
  userInfo: any = {}
  id:any=""
  created() {
        const userInfo = this.$store.state.userStore.userInfo;
        this.userInfo=userInfo;
        distributionGet({}).then(res=>{
         this.distributionUserCount=res.distributionUserCount;
         this.totalDistributionAmount=res.totalDistributionAmount==null?0:res.totalDistributionAmount;
        })
        userIdGet({}).then(res=>{
         this.id=res
      })      
        
    }

  gotocustomer(){
    uni.navigateTo({
      url: `/subcontract/pages/distributionCustomers/distributionCustomers`,
    });
  }
  gotocode(){
    uni.navigateTo({
      url: `/subcontract/pages/promotionCode/promotionCode`,
    });
  }
  async onShareAppMessage() {
    return {
      path: `pages/index/index?userId=${this.id}`,
      };
 
  }

}
</script>

<style lang="scss" scoped>
@import "@/assets/styles/distributionCenter/distributionCenter.scss";
</style>